package com.xxx.mch.schedule;

import com.xxx.mch.service.impl.DepartmentServiceImpl;
import com.xxx.mch.service.impl.UserServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author FengHaixin
 * @description 一句话描述该文件的用途
 * @date 2020/3/4
 */
@Slf4j
@Component
public class AwardSchedule
{

    @Autowired
    private DepartmentServiceImpl departmentService;

    @Autowired
    private UserServiceImpl userServiceImpl;


    //每周六2点更新部门信息
    @Scheduled (cron = "0 0 2 ? * 6")
    public void updateDepartment()
    {
        log.info("定时更新部门信息表");
        departmentService.insertOrUpdate();
        log.info("部门信息表更新结束");
    }

    //每周天1点更新用户信息
    @Scheduled (cron = "0 0 1 ? * 7")
   // @Scheduled (cron = "${updateUserTime}")
    public void updateUser()
    {
        log.info("定时更新用户信息表");
        userServiceImpl.insertOrUpdate();
        log.info("用户信息表更新结束");
    }
}